﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AuctionSite.Entities;

namespace AuctionSite
{
    public partial class SiteMaster : System.Web.UI.MasterPage
    {
        public Usuario UsuarioLogado
        {
            get { return (Usuario)(Session["USUARIO"] ?? (Session["USUARIO"] = null)); }
            set { Session["USUARIO"] = value; }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["Sair"] != null
                && Request.QueryString["Sair"].Equals("T"))
                UsuarioLogado = null;

            NavigationMenu.Items.Add(new MenuItem { NavigateUrl = "~/Default.aspx", Text = "Home" });
            NavigationMenu.Items.Add(new MenuItem { NavigateUrl = "~/Produtos.aspx", Text = "Lista de Produtos" });
            

            if (UsuarioLogado != null)
            {
                NavigationMenu.Items.Add(new MenuItem { NavigateUrl = "~/Usuarios/Perfil.aspx", Text = "Perfil" });
                NavigationMenu.Items.Add(new MenuItem { NavigateUrl = "~/Produtos.aspx?MyProducts=T", Text = "Meus Produtos" });
                lblUsuario.Text = UsuarioLogado.Nome;
                divLoginDisplay.Style.Add(HtmlTextWriterStyle.Display, "block");
            }

            NavigationMenu.Items.Add(new MenuItem { NavigateUrl = "~/About.aspx", Text = "Sobre" });
            
        }
    }
}
